<template>
  <div class="wlm-form">
    <div class="wlm-form-header">佣金设置</div>
    <div class="wlm-form-content">
      <el-form ref="platform" :model="formFormatData.formData" :rules="formFormatData.rules" size="small" label-width="180px" class="retail-form" label-position="right">
        <el-form-item label="是否开启单独团长佣金设置">
          <el-radio-group v-model="formFormatData.formData.is_commission">
            <el-radio :label="2">默认规则</el-radio>
            <el-radio :label="1">单独设置</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="团长佣金类型" >
          <el-radio-group v-model="formFormatData.formData.is_proportion" :disabled='formFormatData.formData.is_commission==2?true:false'>
            <el-radio :label="1">百分比</el-radio>
            <el-radio :label="2">固定金额</el-radio>
          </el-radio-group>

        </el-form-item>
        <el-form-item >
          <el-table :data="formFormatData.formData.sku" :disabled='formFormatData.formData.is_commission==2?true:false'>
            <el-table-column prop="title" label="商品规格"></el-table-column>
            <el-table-column prop="goods_price" label="价格"></el-table-column>
            <el-table-column prop="member_price" label="会员价"></el-table-column>
            <el-table-column prop="commission" label="团长佣金">
              <template slot-scope="scope">
                <el-input v-model="scope.row.commission.money" placeholder="" v-if="formFormatData.formData.is_proportion==2" :disabled='formFormatData.formData.is_commission==2?true:false'>
                  <template slot="append">元</template>
                </el-input>
                <el-input v-model="scope.row.commission.scale" placeholder="" :disabled='formFormatData.formData.is_commission==2?true:false' v-else>
                  <template slot="append">%</template>
                </el-input>
              </template>
            </el-table-column>
          </el-table>
        </el-form-item>
      </el-form>
    </div>
    <div v-cloak class="wlm-fixed-btn flex-row flex-align-c flex-justify-c">
      <el-button size="small" type="primary" @click="formFormatSubmit({ router: { type: 'push', path: '/merchandise/merchandiseManagement', code: 1 } })">保存</el-button>
      <router-link tag="span" to="/merchandise/merchandiseManagement">
        <el-button size="small">返回</el-button>
      </router-link>
    </div>
  </div>
</template>

<script>
import { supplierregmoney, suppliergetregmoney } from '@/api/commityBuy'
import mixins from '@/mixins/mixins'
export default {
  mixins: [mixins.getters('Form')],
  data() {
    return {
      formFormatData: {
        api: {
          editForm: {
            api: suppliergetregmoney,
            params: {
              id: ''
            },
            redirect: 'goods_id'
          },
          submitForm: supplierregmoney
        },
        formData: {
          is_proportion: 2,
          is_commission: 1,
          sku: []
        }
      }

    }
  }

}
</script>

<style>
</style>
